<h2>DESCRIPTION</h2> 

This program allows a user to convert coordinates from one projection
to another. Coordinates can be read from one file, converted, and
results written to another file. Alternatively, if the <b>input=-</b>,
eastings and northings may be passed to the program directly from
standard input. If the <b>output</b> option is omitted, the results
are sent directly to standard output. In this way <em>m.proj</em> can
be used as a simple frontend to
the <a href="https://proj.org/apps/cs2cs.html">PROJ</a>
<em>cs2cs</em> utility. The <b>-i</b> or <b>-o</b> flags make the task
especially easy for the common problem of converting to or from lat/long
WGS84.
<p>
<i>Note</i>: This program does not transform GRASS maps, it is
designed to determine the equivalent coordinate values of an
individual position or list of
positions. Use <em><a href="v.proj.html">v.proj</a></em> to reproject
vector maps or <em><a href="r.proj.html">r.proj</a></em> for raster maps.
<p>
For an introduction to map projections (with PROJ),see the manual page of
<a href="r.proj.html">r.proj</a>.

<h2>NOTES</h2>

<em>cs2cs</em> expects input data to formatted as <tt>x y</tt>, so if
working with latitude-longitude data be sure to send the <tt>x</tt>
value first, i.e., <tt>longitude&nbsp;latitude</tt>. Output data will
be exported using the same convention.
<p>
<em>cs2cs</em> will treat a third data column as a <tt>z</tt> value
(elevation) and will modify the value accordingly. This usually
translates into small but real differences in that data column.
<p>
<em>cs2cs</em> does not expect the input stream to contain column
headings, only numbers. If your data file has lines you wish to have
passed through without being processed, they must start with the
'<tt>#</tt>' character.
<p>
If sending <em>m.proj</em> data from standard input, be aware that the
data is first stored to a temporary file before being processed
with <em>cs2cs</em>.  It is therefore not advisable to
send <em>m.proj</em> data from an open data stream. The module will
stop listening for incoming data after 2 seconds of inactivity. You
may use the projection parameters gleaned from <em>m.proj</em>'s
verbose mode (<b>--verbose</b>) with <em>cs2cs</em> directly in this case.
<p>
Custom projection parameters can be used via the <b>proj_in</b> and
<b>proj_out</b> options. Full documentation of the projection
parameter format may be found on
the <a href="https://proj.org">PROJ</a> website. Using
these options will fully override the default parameters the module
would normally use.
<p>
By using the <b>--verbose</b> verbose flag, the user can see exactly
what projection parameters will be used in the conversion as well as
some other informative messages.
<p>
If output is to lat/long, it will be formatted using PROJ's
Degree:Minute:Second (DMS) convention
of <tt>DDDdMM'SSS.SS"H</tt>. This can be handy if you wish to quickly
convert lat/long decimal degree data into its DMS equivalent.<br>
Alternatively, to have <em>m.proj</em> output data in decimal degrees,
use the <b>-d</b> flag. This flag can also be used with non-lat/long
data to force a higher number of decimal places (the <em>cs2cs</em>
default is 2).
<p>
Note that Lat/long output can be converted to GRASS's DMS convention
(<tt>DDD:MM:SSS.SSSH</tt>) by piping the results of <em>m.proj</em>
through the <em>sed</em> stream editor as follows.

<div class="code"><pre>
m.proj -o ... | sed -e 's/d/:/g' -e "s/'/:/g"  -e 's/"//g'
</pre></div>

<h2>EXAMPLES</h2>

The examples are suitable for the North Carolina sample dataset if not
stated otherwise:

<h3>Reproject vector point coordinate pairs to Long/Lat WGS84</h3>

<p>
The <em>m.proj</em> module is designed to work seamlessly with point
data exported from the GIS
with <em><a href="v.out.ascii.html">v.out.ascii</a></em>, as the
following example shows.

<div class="code"><pre>
# Long/Lat WGS84 output in DMS
v.out.ascii bridges | m.proj -o input=-

# Long/Lat WGS84 output in decimal degree
v.out.ascii bridges | m.proj -o -d input=-
</pre></div>

<h3>Reproject Long/Lat WGS84 coordinate pair to current map projection</h3>

To convert a Long/Lat WGS84 coordinate pair to the current map projection
using the <b>-i</b> flag which sets the target projection parameters
automatically from the current location definition:
<div class="code"><pre>
echo "-78.61168178 33.92225767" | m.proj -i input=-
645513.47|19180.31|0.00
</pre></div>

<p>
The same, but load points from a file named <tt>waypoints.txt</tt> and
continue on to import the results into a GRASS vector points map in
the current map projection:
<div class="code"><pre>
# check file content
cat waypoints.txt 
-78.43977824 33.89587173
-78.54944691 33.88964566
-78.51078074 33.88141495
-77.14037951 35.60543020

# reproject points and generate vector map on the fly
m.proj -i input=waypoints.txt | v.in.ascii input=- output=test_pnts 

# verify result
v.db.select test_pnts cat|dbl_1|dbl_2|dbl_3
1|661427.74|16329.14|0
2|651285.43|15586.79|0
3|654867.21|14690.64|0
4|778074.58|207402.6|0
</pre></div>


<h3>Custom projection parameter usage</h3>

To transform points from a UTM projection (here specified with detailed
projection definition rather than using an EPSG code) into the
Gauss-Kr&uuml;ger Grid System, importing from and exporting to files:

<div class="code"><pre>
m.proj proj_in="+proj=utm +name=utm +a=6378137.0 +es=0.006694380 \
    +zone=32 +unfact=1.0" proj_out="+proj=tmerc +name=tmerc \
    +a=6377397.155 +es=0.0066743720 +lat_0=0.0 +lon_0=9.0 +k=1.0 \
    +x_0=3500000.0" input=utm.coord.txt output=new.gk.coord.txt
</pre></div>

<p>
Projection parameters provided in the above case: <tt>+proj</tt>
(projection type), <tt>+name</tt> (projection name), <tt>+a</tt>
(ellipsoid: equatorial radius), <tt>+es</tt> (ellipsoid:
eccentricity squared), <tt>+zone</tt> (zone for the area),
<tt>+unfact</tt> (conversion factor from meters to other units,
e.g. feet), <tt>+lat_0</tt> (standard parallel), <tt>+lon_0</tt>
(central meridian), <tt>+k</tt> (scale factor) and <tt>+x_0</tt>
(false easting). Sometimes false northing is needed which is coded as
<tt>+y_0</tt>.  Internally, the underlying
<a href="https://proj.org">PROJ</a> projection library
performs an inverse projection to latitude-longitude and then projects
the coordinate list to the target projection.
<p>
Datum conversions are automatically handled by the PROJ library if
<tt>+datum</tt> setings are specified on <b>both</b> the input <b>and</b> output
projections on the command line. The <tt>+towgs84</tt> parameter can be used to 
define either 3 or 7 term datum transform coefficients, satisfying this requirement.
<p>If a datum is specified there is no need for the <tt>+ellps=</tt> or underlying
parameters, <tt>+a=</tt>, <tt>+es=</tt>, etc.

<p>
Another custom parameter usage example:

<div class="code"><pre>
m.proj proj_in="+proj=tmerc +datum=ire65 +lat_0=53.5 +lon_0=-8 +x_0=200000 \
    +y_0=250000 +k=1.000035" proj_out="+proj=ll +datum=wgs84" input=wpt.txt
</pre></div>

or without datum transformation:

<div class="code"><pre>
m.proj proj_in="+proj=tmerc +ellps=modif_airy +lat_0=53.5 +lon_0=-8 +x_0=200000 \
    +y_0=250000 +k=1.000035" proj_out="+proj=ll +datum=wgs84" input=wpt.txt
</pre></div>

<p>
In this example no datum transformation will take place as a datum was
not specified for the input projection. The datum specified for the
output projection will thus be silently ignored and may be left out;
all that is achieved a simple conversion from projected to geodetic
co-ordinates, keeping the same datum (and thus also the same
ellipsoid).

<p>
For more usage examples, see the documentation for the
<a href="https://proj.org">PROJ</a> <em>cs2cs</em> program.


<h2>REFERENCES</h2>

<ul>
  <li>Evenden, G.I.
      (1990) <a href="https://pubs.usgs.gov/of/1990/of90-284/ofr90-284.pdf">Cartographic
      projection procedures for the UNIX environment - a user's
      manual</a>.  USGS Open-File Report 90-284 (OF90-284.pdf) See
      also there: Interim Report and 2nd Interim Report on Release 4,
      Evenden 1994).</li>
  <li><a href="https://proj.org">PROJ</a> Cartographic Projection Library</li>
</ul>

<h2>SEE ALSO</h2>

<em>
<a href="g.proj.html">g.proj</a>,
<a href="r.proj.html">r.proj</a>,
<a href="v.proj.html">v.proj</a>,
<a href="i.rectify.html">i.rectify</a>,
<a href="v.in.ascii.html">v.in.ascii</a>,
<a href="v.out.ascii.html">v.out.ascii</a>
</em>


<h2>AUTHOR</h2>

M. Hamish Bowman, Dept. Marine Science, Otago University, New Zealand<br>
Functionality inspired by the <em>m.proj</em> and <em>m.proj2</em> modules for
GRASS GIS 5.

<!--
<p>
<i>Last changed: $Date$</i>
-->
